﻿<html>
<head>
<link href="css/qam.css" rel="stylesheet" media="screen" />
<style>
#group_box{display:inline-block;}
</style>
</head>
<body>

	<div style="width:960px;margin:0 auto">
		<div id="message" ></div>
		
		<HR><h3>系统设置</h3>
		<div style="padding:10px;background:#E8E8FF;margin-top:10px;">
			<form method="post" action="#" name="myform" class="myform">
				<input type="hidden" value="12" name="page_id" />
				<label><span>图片</span>
				<input type="hidden" value="" name="img_data" />
				<input type="hidden" value="" name="name" />
				<input type="file" id="file" size="10" multiple="true" onchange="select_img(this.files)" /><BR />
			
				<input type="button" value="修改" onclick="upload();" name="button"  />
			</form>
			<img src="" id="img_test" />
		</div>
	</div>



</body>

<script src="js/ajax.js" type="text/javascript"></script>
<script src="js/md5.js" type="text/javascript"></script>
<script src="js/function.js" type="text/javascript"></script>
<script>



function init(){}

//html5 选择文件
function select_img(myFiles) {
  for (var i = 0, f; f = myFiles[i]; i++) {
    var imageReader = new FileReader();
    imageReader.onload = (function(aFile) {
      return function(e) {
		 document.myform.name.value="asdf/123.jpg";
        document.myform.img_data.value=e.target.result;
      };
	  
    })(f);
    imageReader.readAsDataURL(f);
  }
}


function upload(){
	var _url=cgipath+"image-upload";
	var ajax_obj=new AJAX_OBJ(_url,handle_update,handle_error,5000);
	ajax_obj.postData(formToString(document.myform));
}

function handle_update(xmlHttp){
	//$$("message").innerHTML=xmlHttp.responseText;return;
	eval("var ret_json="+xmlHttp.responseText);
	$$("message").innerHTML="【ret】"+ret_json.ret+"【msg】"+ret_json.msg;
	$$("img_test").src=cgipath+ret_json.img;
}

</script>
<script src="js/public.js" type="text/javascript"></script>


</html>